﻿using System;
using System.Data;
using System.Windows.Forms;
using myDBConnection = System.Data.SqlClient.SqlConnection;
using myDBTransaction = System.Data.SqlClient.SqlTransaction;
using YNCNumberSys.db;
using cadApp = Autodesk.AutoCAD.ApplicationServices.Application;
/// <summary>
/// XSL 已经核查一遍20221121。
/// </summary>
namespace YNCNumberSys
{
    public partial class UsmNewUser : Form
    {
        private CommandManager commandManager = new CommandManager();
        private ConnectionManager connectionManager = new ConnectionManager();
        private DataTable m_用户 = new DataTable();

        public UsmNewUser()
        {
            InitializeComponent();
        }

        private void btn_确定_Click(object sender, EventArgs e)
        {
            if (this.tbx_用户名.Text == string.Empty)
            {
                cadApp.ShowAlertDialog(@"用户名不能为空！");
                return;
            }
            if (this.tbx_姓名.Text == string.Empty)
            {
                cadApp.ShowAlertDialog(@"姓名不能为空！");
                return;
            }
            if (this.tbx_新密码.Text != this.tbx_确认密码.Text)
            {
                cadApp.ShowAlertDialog(@"两次密码不一致，请重新输入！");
                return;
            }
            userDal dal = new userDal();
            bool rt = dal.Insert(this.tbx_用户名.Text, EnOrDeEncryptHelper.EncryptText("123"), this.tbx_姓名.Text);
            if (!rt)
                cadApp.ShowAlertDialog(@"用户名已存在，请重新命名！");
            else
                DialogResult = DialogResult.OK;

        }

        private void UsmNewUser_FormClosed(object sender, FormClosedEventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}
